
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/interactive.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:24:29 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Interactive &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../live.sympy.org/static/live-sphinx.js"></script>
    
    <link rel="shortcut icon" href="../_static/sympy-notailtext-favicon.ico"/>
    <link href="interactive.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Lie Algebra" href="liealgebras/index.html" />
    <link rel="prev" title="Computing Integrals using Meijer G-Functions" href="integrals/g-functions.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="liealgebras/index.html" title="Lie Algebra"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="integrals/g-functions.html" title="Computing Integrals using Meijer G-Functions"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Interactive</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-sympy.interactive">
<span id="interactive"></span><h1>Interactive<a class="headerlink" href="#module-sympy.interactive" title="Permalink to this headline">¶</a></h1>
<p>Helper module for setting up interactive SymPy sessions.</p>
<section id="module-sympy.interactive.session">
<span id="session"></span><h2>Session<a class="headerlink" href="#module-sympy.interactive.session" title="Permalink to this headline">¶</a></h2>
<p>Tools for setting up interactive sessions.</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.interactive.session.enable_automatic_int_sympification">
<span class="sig-prename descclassname"><span class="pre">sympy.interactive.session.</span></span><span class="sig-name descname"><span class="pre">enable_automatic_int_sympification</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shell</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/interactive/session.py#L138-L159"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.interactive.session.enable_automatic_int_sympification" title="Permalink to this definition">¶</a></dt>
<dd><p>Allow IPython to automatically convert integer literals to Integer.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.interactive.session.enable_automatic_symbols">
<span class="sig-prename descclassname"><span class="pre">sympy.interactive.session.</span></span><span class="sig-name descname"><span class="pre">enable_automatic_symbols</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shell</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/interactive/session.py#L162-L230"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.interactive.session.enable_automatic_symbols" title="Permalink to this definition">¶</a></dt>
<dd><p>Allow IPython to automatically create symbols (<code class="docutils literal notranslate"><span class="pre">isympy</span> <span class="pre">-a</span></code>).</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.interactive.session.init_ipython_session">
<span class="sig-prename descclassname"><span class="pre">sympy.interactive.session.</span></span><span class="sig-name descname"><span class="pre">init_ipython_session</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shell</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">argv</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">[]</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto_symbols</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto_int_to_Integer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/interactive/session.py#L233-L263"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.interactive.session.init_ipython_session" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct new IPython session.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.interactive.session.init_python_session">
<span class="sig-prename descclassname"><span class="pre">sympy.interactive.session.</span></span><span class="sig-name descname"><span class="pre">init_python_session</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/interactive/session.py#L266-L298"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.interactive.session.init_python_session" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct new Python session.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.interactive.session.init_session">
<span class="sig-prename descclassname"><span class="pre">sympy.interactive.session.</span></span><span class="sig-name descname"><span class="pre">init_session</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ipython</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pretty_print</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_unicode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_latex</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">quiet</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto_symbols</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto_int_to_Integer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">str_printer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pretty_printer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">latex_printer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">argv</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">[]</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/interactive/session.py#L301-L464"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.interactive.session.init_session" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize an embedded IPython or Python session. The IPython session is
initiated with the –pylab option, without the numpy imports, so that
matplotlib plotting can be interactive.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>pretty_print: boolean</strong></p>
<blockquote>
<div><p>If True, use pretty_print to stringify;
if False, use sstrrepr to stringify.</p>
</div></blockquote>
<p><strong>order: string or None</strong></p>
<blockquote>
<div><p>There are a few different settings for this parameter:
lex (default), which is lexographic order;
grlex, which is graded lexographic order;
grevlex, which is reversed graded lexographic order;
old, which is used for compatibility reasons and for long expressions;
None, which sets it to lex.</p>
</div></blockquote>
<p><strong>use_unicode: boolean or None</strong></p>
<blockquote>
<div><p>If True, use unicode characters;
if False, do not use unicode characters.</p>
</div></blockquote>
<p><strong>use_latex: boolean or None</strong></p>
<blockquote>
<div><p>If True, use latex rendering if IPython GUI’s;
if False, do not use latex rendering.</p>
</div></blockquote>
<p><strong>quiet: boolean</strong></p>
<blockquote>
<div><p>If True, init_session will not print messages regarding its status;
if False, init_session will print messages regarding its status.</p>
</div></blockquote>
<p><strong>auto_symbols: boolean</strong></p>
<blockquote>
<div><p>If True, IPython will automatically create symbols for you.
If False, it will not.
The default is False.</p>
</div></blockquote>
<p><strong>auto_int_to_Integer: boolean</strong></p>
<blockquote>
<div><p>If True, IPython will automatically wrap int literals with Integer, so
that things like 1/2 give Rational(1, 2).
If False, it will not.
The default is False.</p>
</div></blockquote>
<p><strong>ipython: boolean or None</strong></p>
<blockquote>
<div><p>If True, printing will initialize for an IPython console;
if False, printing will initialize for a normal console;
The default is None, which automatically determines whether we are in
an ipython instance or not.</p>
</div></blockquote>
<p><strong>str_printer: function, optional, default=None</strong></p>
<blockquote>
<div><p>A custom string printer function. This should mimic
sympy.printing.sstrrepr().</p>
</div></blockquote>
<p><strong>pretty_printer: function, optional, default=None</strong></p>
<blockquote>
<div><p>A custom pretty printer. This should mimic sympy.printing.pretty().</p>
</div></blockquote>
<p><strong>latex_printer: function, optional, default=None</strong></p>
<blockquote>
<div><p>A custom LaTeX printer. This should mimic sympy.printing.latex()
This should mimic sympy.printing.latex().</p>
</div></blockquote>
<p><strong>argv: list of arguments for IPython</strong></p>
<blockquote>
<div><p>See sympy.bin.isympy for options that can be used to initialize IPython.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">init_session</span><span class="p">,</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">sin</span><span class="p">,</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> 
<span class="go">NameError: name &#39;x&#39; is not defined</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_session</span><span class="p">()</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> 
<span class="go">sin(x)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span> 
<span class="go">  ___</span>
<span class="go">\/ 5</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_session</span><span class="p">(</span><span class="n">pretty_print</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span> 
<span class="go">sqrt(5)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> 
<span class="go">x**2 + x + y**2 + y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_session</span><span class="p">(</span><span class="n">order</span><span class="o">=</span><span class="s1">&#39;grlex&#39;</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> 
<span class="go">x**2 + y**2 + x + y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_session</span><span class="p">(</span><span class="n">order</span><span class="o">=</span><span class="s1">&#39;grevlex&#39;</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">y</span> <span class="o">*</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">*</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span> 
<span class="go">x**2*y + x*y**2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_session</span><span class="p">(</span><span class="n">order</span><span class="o">=</span><span class="s1">&#39;old&#39;</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span> 
<span class="go">x + y + x**2 + y**2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">theta</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;theta&#39;</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">theta</span> 
<span class="go">theta</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_session</span><span class="p">(</span><span class="n">use_unicode</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">theta</span> 
<span class="go">θ</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#sympy.interactive.printing.init_printing" title="sympy.interactive.printing.init_printing"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.interactive.printing.init_printing</span></code></a></dt><dd><p>for examples and the rest of the parameters.</p>
</dd>
</dl>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.interactive.session.int_to_Integer">
<span class="sig-prename descclassname"><span class="pre">sympy.interactive.session.</span></span><span class="sig-name descname"><span class="pre">int_to_Integer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/interactive/session.py#L85-L135"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.interactive.session.int_to_Integer" title="Permalink to this definition">¶</a></dt>
<dd><p>Wrap integer literals with Integer.</p>
<p>This is based on the decistmt example from
<a class="reference external" href="http://docs.python.org/library/tokenize.html">http://docs.python.org/library/tokenize.html</a>.</p>
<p>Only integer literals are converted.  Float literals are left alone.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">division</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Integer</span> <span class="c1"># noqa: F401</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.interactive.session</span> <span class="kn">import</span> <span class="n">int_to_Integer</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="s1">&#39;1.2 + 1/2 - 0x12 + a1&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">int_to_Integer</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
<span class="go">&#39;1.2 +Integer (1 )/Integer (2 )-Integer (0x12 )+a1 &#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="s1">&#39;print (1/2)&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">int_to_Integer</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
<span class="go">&#39;print (Integer (1 )/Integer (2 ))&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">exec</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
<span class="go">0.5</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">exec</span><span class="p">(</span><span class="n">int_to_Integer</span><span class="p">(</span><span class="n">s</span><span class="p">))</span>
<span class="go">1/2</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="module-sympy.interactive.printing">
<span id="printing"></span><h2>Printing<a class="headerlink" href="#module-sympy.interactive.printing" title="Permalink to this headline">¶</a></h2>
<p>Tools for setting up printing in interactive sessions.</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.interactive.printing.init_printing">
<span class="sig-prename descclassname"><span class="pre">sympy.interactive.printing.</span></span><span class="sig-name descname"><span class="pre">init_printing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pretty_print</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_unicode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_latex</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">wrap_line</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_columns</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">no_global</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ip</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">euler</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">forecolor</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">backcolor</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'Transparent'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fontsize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'10pt'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">latex_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'plain'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">print_builtin</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">str_printer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pretty_printer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">latex_printer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">scale</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">settings</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/interactive/printing.py#L339-L573"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.interactive.printing.init_printing" title="Permalink to this definition">¶</a></dt>
<dd><p>Initializes pretty-printer depending on the environment.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>pretty_print</strong> : boolean, default=True</p>
<blockquote>
<div><p>If True, use pretty_print to stringify or the provided pretty
printer; if False, use sstrrepr to stringify or the provided string
printer.</p>
</div></blockquote>
<p><strong>order</strong> : string or None, default=’lex’</p>
<blockquote>
<div><p>There are a few different settings for this parameter:
lex (default), which is lexographic order;
grlex, which is graded lexographic order;
grevlex, which is reversed graded lexographic order;
old, which is used for compatibility reasons and for long expressions;
None, which sets it to lex.</p>
</div></blockquote>
<p><strong>use_unicode</strong> : boolean or None, default=None</p>
<blockquote>
<div><p>If True, use unicode characters;
if False, do not use unicode characters;
if None, make a guess based on the environment.</p>
</div></blockquote>
<p><strong>use_latex</strong> : string, boolean, or None, default=None</p>
<blockquote>
<div><p>If True, use default LaTeX rendering in GUI interfaces (png and
mathjax);
if False, do not use LaTeX rendering;
if None, make a guess based on the environment;
if ‘png’, enable latex rendering with an external latex compiler,
falling back to matplotlib if external compilation fails;
if ‘matplotlib’, enable LaTeX rendering with matplotlib;
if ‘mathjax’, enable LaTeX text generation, for example MathJax
rendering in IPython notebook or text rendering in LaTeX documents;
if ‘svg’, enable LaTeX rendering with an external latex compiler,
no fallback</p>
</div></blockquote>
<p><strong>wrap_line</strong> : boolean</p>
<blockquote>
<div><p>If True, lines will wrap at the end; if False, they will not wrap
but continue as one line. This is only relevant if <code class="docutils literal notranslate"><span class="pre">pretty_print</span></code> is
True.</p>
</div></blockquote>
<p><strong>num_columns</strong> : int or None, default=None</p>
<blockquote>
<div><p>If int, number of columns before wrapping is set to num_columns; if
None, number of columns before wrapping is set to terminal width.
This is only relevant if <code class="docutils literal notranslate"><span class="pre">pretty_print</span></code> is True.</p>
</div></blockquote>
<p><strong>no_global</strong> : boolean, default=False</p>
<blockquote>
<div><p>If True, the settings become system wide;
if False, use just for this console/session.</p>
</div></blockquote>
<p><strong>ip</strong> : An interactive console</p>
<blockquote>
<div><p>This can either be an instance of IPython,
or a class that derives from code.InteractiveConsole.</p>
</div></blockquote>
<p><strong>euler</strong> : boolean, optional, default=False</p>
<blockquote>
<div><p>Loads the euler package in the LaTeX preamble for handwritten style
fonts (<a class="reference external" href="http://www.ctan.org/pkg/euler">http://www.ctan.org/pkg/euler</a>).</p>
</div></blockquote>
<p><strong>forecolor</strong> : string or None, optional, default=None</p>
<blockquote>
<div><p>DVI setting for foreground color. None means that either ‘Black’,
‘White’, or ‘Gray’ will be selected based on a guess of the IPython
terminal color setting. See notes.</p>
</div></blockquote>
<p><strong>backcolor</strong> : string, optional, default=’Transparent’</p>
<blockquote>
<div><p>DVI setting for background color. See notes.</p>
</div></blockquote>
<p><strong>fontsize</strong> : string, optional, default=’10pt’</p>
<blockquote>
<div><p>A font size to pass to the LaTeX documentclass function in the
preamble. Note that the options are limited by the documentclass.
Consider using scale instead.</p>
</div></blockquote>
<p><strong>latex_mode</strong> : string, optional, default=’plain’</p>
<blockquote>
<div><p>The mode used in the LaTeX printer. Can be one of:
{‘inline’|’plain’|’equation’|’equation*’}.</p>
</div></blockquote>
<p><strong>print_builtin</strong> : boolean, optional, default=True</p>
<blockquote>
<div><p>If <code class="docutils literal notranslate"><span class="pre">True</span></code> then floats and integers will be printed. If <code class="docutils literal notranslate"><span class="pre">False</span></code> the
printer will only print SymPy types.</p>
</div></blockquote>
<p><strong>str_printer</strong> : function, optional, default=None</p>
<blockquote>
<div><p>A custom string printer function. This should mimic
sympy.printing.sstrrepr().</p>
</div></blockquote>
<p><strong>pretty_printer</strong> : function, optional, default=None</p>
<blockquote>
<div><p>A custom pretty printer. This should mimic sympy.printing.pretty().</p>
</div></blockquote>
<p><strong>latex_printer</strong> : function, optional, default=None</p>
<blockquote>
<div><p>A custom LaTeX printer. This should mimic sympy.printing.latex().</p>
</div></blockquote>
<p><strong>scale</strong> : float, optional, default=1.0</p>
<blockquote>
<div><p>Scale the LaTeX output when using the <code class="docutils literal notranslate"><span class="pre">png</span></code> or <code class="docutils literal notranslate"><span class="pre">svg</span></code> backends.
Useful for high dpi screens.</p>
</div></blockquote>
<p><strong>settings :</strong></p>
<blockquote>
<div><p>Any additional settings for the <code class="docutils literal notranslate"><span class="pre">latex</span></code> and <code class="docutils literal notranslate"><span class="pre">pretty</span></code> commands can
be used to fine-tune the output.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.interactive</span> <span class="kn">import</span> <span class="n">init_printing</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
<span class="go">sqrt(5)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_printing</span><span class="p">(</span><span class="n">pretty_print</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">sqrt</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span> 
<span class="go">  ___</span>
<span class="go">\/ 5</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">theta</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;theta&#39;</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_printing</span><span class="p">(</span><span class="n">use_unicode</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">theta</span> 
<span class="go">\u03b8</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_printing</span><span class="p">(</span><span class="n">use_unicode</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">theta</span> 
<span class="go">theta</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_printing</span><span class="p">(</span><span class="n">order</span><span class="o">=</span><span class="s1">&#39;lex&#39;</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="nb">str</span><span class="p">(</span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span> 
<span class="go">x**2 + x + y**2 + y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_printing</span><span class="p">(</span><span class="n">order</span><span class="o">=</span><span class="s1">&#39;grlex&#39;</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="nb">str</span><span class="p">(</span><span class="n">y</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span> 
<span class="go">x**2 + x + y**2 + y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_printing</span><span class="p">(</span><span class="n">order</span><span class="o">=</span><span class="s1">&#39;grevlex&#39;</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="nb">str</span><span class="p">(</span><span class="n">y</span> <span class="o">*</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">*</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span> 
<span class="go">x**2*y + x*y**2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_printing</span><span class="p">(</span><span class="n">order</span><span class="o">=</span><span class="s1">&#39;old&#39;</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="p">)</span> 
<span class="go">x**2 + x + y**2 + y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">init_printing</span><span class="p">(</span><span class="n">num_columns</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span> 
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span> 
<span class="go">x + y +</span>
<span class="go">x**2 + y**2</span>
</pre></div>
</div>
<p class="rubric">Notes</p>
<p>The foreground and background colors can be selected when using ‘png’ or
‘svg’ LaTeX rendering. Note that before the <code class="docutils literal notranslate"><span class="pre">init_printing</span></code> command is
executed, the LaTeX rendering is handled by the IPython console and not SymPy.</p>
<p>The colors can be selected among the 68 standard colors known to <code class="docutils literal notranslate"><span class="pre">dvips</span></code>,
for a list see <a class="reference internal" href="#r517" id="id1"><span>[R517]</span></a>. In addition, the background color can be
set to  ‘Transparent’ (which is the default value).</p>
<p>When using the ‘Auto’ foreground color, the guess is based on the
<code class="docutils literal notranslate"><span class="pre">colors</span></code> variable in the IPython console, see <a class="reference internal" href="#r518" id="id2"><span>[R518]</span></a>. Hence, if
that variable is set correctly in your IPython console, there is a high
chance that the output will be readable, although manual settings may be
needed.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="printing.html#module-sympy.printing.latex" title="sympy.printing.latex"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.printing.latex</span></code></a>, <a class="reference internal" href="printing.html#module-sympy.printing.pretty" title="sympy.printing.pretty"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.printing.pretty</span></code></a></p>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r517"><span class="brackets">R517</span><span class="fn-backref">(<a href="#id1">1</a>,<a href="#id3">2</a>)</span></dt>
<dd><p><a class="reference external" href="https://en.wikibooks.org/wiki/LaTeX/Colors#The_68_standard_colors_known_to_dvips">https://en.wikibooks.org/wiki/LaTeX/Colors#The_68_standard_colors_known_to_dvips</a></p>
</dd>
<dt class="label" id="r518"><span class="brackets">R518</span><span class="fn-backref">(<a href="#id2">1</a>,<a href="#id4">2</a>)</span></dt>
<dd><p><a class="reference external" href="https://ipython.readthedocs.io/en/stable/config/details.html#terminal-colors">https://ipython.readthedocs.io/en/stable/config/details.html#terminal-colors</a></p>
</dd>
</dl>
</dd></dl>

</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Interactive</a><ul>
<li><a class="reference internal" href="#module-sympy.interactive.session">Session</a></li>
<li><a class="reference internal" href="#module-sympy.interactive.printing">Printing</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="integrals/g-functions.html"
                        title="previous chapter">Computing Integrals using Meijer G-Functions</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="liealgebras/index.html"
                        title="next chapter">Lie Algebra</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/modules/interactive.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="liealgebras/index.html" title="Lie Algebra"
             >next</a> |</li>
        <li class="right" >
          <a href="integrals/g-functions.html" title="Computing Integrals using Meijer G-Functions"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" >SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Interactive</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/interactive.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:24:29 GMT -->
</html>